﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SerialPort2Socket
{
    class ConvertHepler
    {
        /// <summary>
        /// 字节数据转十六进制数
        /// </summary>
        /// <param name="data">字节数组</param>
        /// <returns>十六进制数（大写）</returns>
        public static string ByteToHex(byte[] data)
        {
            string result = string.Empty;

            if (data != null && data.Length > 0)
            {
                for (int i = 0; i < data.Length; i++)
                {
                    result += data[i].ToString("X2");
                }
            }
            return result;
        }
    }
}
